package com.article.exceptionhandler;

import com.article.dto.ReturnError;
import com.article.enums.ReturnInfoEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/5/31.
 */
@ControllerAdvice
public class Handler {

    private static final Logger log = LoggerFactory.getLogger(Handler.class);

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ReturnError handleException(Exception e) {
        log.info("ERROR",e);
        return new ReturnError(true, ReturnInfoEnum.ERROR.getType(), e.getMessage());
    }

}
